﻿using Corp.Proj.Model;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Text;
using System.Threading.Tasks;

namespace Corp.Proj.DAL
{
    public class EFDbContextFactory
    {
        public static DbContext GetCurrentDbContext()
        {
            //线程内的单例：保证线程内实例唯一
            DbContext db = (DbContext)CallContext.GetData("DbContext");
            if (db == null)
            {
                db = new Entities();

                CallContext.SetData("DbContext", db);
            }
            return db;
        }
    }
}
